package model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the party database table.
 * 
 */
@Entity
@NamedQuery(name="Party.findAll", query="SELECT p FROM Party p")
public class Party implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int idParty;

	private int creatorid;

	@Temporal(TemporalType.DATE)
	private Date dateCreate;

	private String name;

	@Lob
	private String program;

	@Lob
	private String symbol;

	//bi-directional many-to-one association to Member
	@OneToMany(mappedBy="party")
	private List<Member> members;

	//bi-directional one-to-one association to Vote
	@OneToOne
	@PrimaryKeyJoinColumn
	//@JoinColumn(name="idParty", referencedColumnName="idParty")
	private Vote vote;

	//bi-directional many-to-one association to Subscribe
	@OneToMany(mappedBy="party")
	private List<Subscribe> subscribes;

	//bi-directional many-to-one association to Vote
	@OneToMany(mappedBy="party2")
	private List<Vote> votes;

	public Party() {
	}

	public int getIdParty() {
		return this.idParty;
	}

	public void setIdParty(int idParty) {
		this.idParty = idParty;
	}

	public int getCreatorid() {
		return this.creatorid;
	}

	public void setCreatorid(int creatorid) {
		this.creatorid = creatorid;
	}

	public Date getDateCreate() {
		return this.dateCreate;
	}

	public void setDateCreate(Date dateCreate) {
		this.dateCreate = dateCreate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getProgram() {
		return this.program;
	}

	public void setProgram(String program) {
		this.program = program;
	}

	public String getSymbol() {
		return this.symbol;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	public List<Member> getMembers() {
		return this.members;
	}

	public void setMembers(List<Member> members) {
		this.members = members;
	}

	public Member addMember(Member member) {
		getMembers().add(member);
		member.setParty(this);

		return member;
	}

	public Member removeMember(Member member) {
		getMembers().remove(member);
		member.setParty(null);

		return member;
	}

	public Vote getVote() {
		return this.vote;
	}

	public void setVote(Vote vote) {
		this.vote = vote;
	}

	public List<Subscribe> getSubscribes() {
		return this.subscribes;
	}

	public void setSubscribes(List<Subscribe> subscribes) {
		this.subscribes = subscribes;
	}

	public Subscribe addSubscribe(Subscribe subscribe) {
		getSubscribes().add(subscribe);
		subscribe.setParty(this);

		return subscribe;
	}

	public Subscribe removeSubscribe(Subscribe subscribe) {
		getSubscribes().remove(subscribe);
		subscribe.setParty(null);

		return subscribe;
	}

	public List<Vote> getVotes() {
		return this.votes;
	}

	public void setVotes(List<Vote> votes) {
		this.votes = votes;
	}

	public Vote addVote(Vote vote) {
		getVotes().add(vote);
		vote.setParty2(this);

		return vote;
	}

	public Vote removeVote(Vote vote) {
		getVotes().remove(vote);
		vote.setParty2(null);

		return vote;
	}

}